package com.flute.framework.data.mysql;

import java.util.List;

import org.amino.ds.lockfree.LockFreeList;
import org.apache.commons.lang.StringUtils;

import com.flute.framework.data.constants.Constants;

public final class WhereSQL {
	private List<String> whereClauses;

	public void addWhereClause(String where) {
		if (whereClauses == null) {
			whereClauses = new LockFreeList<String>();
		}
		if (!whereClauses.contains(where)) {
			whereClauses.add(where);
		}
	}

	public String toSQL() {
		if (whereClauses == null || whereClauses.isEmpty()) {
			return Constants.EMPTY;
		}
		return Constants.WHERE + StringUtils.join(whereClauses, Constants.AND);
	}
}
